import { defineArray } from "../reactive/defineArray.mjs";
import assert from "assert";
import { defineReactive } from "../reactive/defineReactive.mjs";
import { Watcher } from "../reactive/watcher.mjs";

describe('测试defineArray', function () {
    it('数组的push方法', function () {
        const arr = [];
        let n = 0;
        defineArray(arr, 'push', function () {
            n++;
        })
        arr.push(1);
        assert.equal(n, 1);
    })
})

describe('测试watcher', function () {
    it('使用defineReactive与watcher', function () {
        const vm = { m: 12 }
        defineReactive(vm, 'm', vm.m)
        let i = 0;
        new Watcher(vm, 'm', function () {
            console.log(vm.m);
            i++;
        })
        vm.m = 14;
        assert.equal(i, 1);
    })
})